#include "pch.h"
#include "ParticleData.h"

CParticleData::~CParticleData()
{
	m_masses.clear();
	m_invMasses.clear();
	m_x0.clear();
	m_x.clear();
	m_v.clear();
	m_a.clear();
	m_oldX.clear();
	m_lastX.clear();
}

void CParticleData::addParticle(const Eigen::Vector3d& vPos)
{
	m_x0.push_back(vPos);
	m_x.push_back(vPos);
	m_oldX.push_back(vPos);
	m_lastX.push_back(vPos);
	m_masses.push_back(1.0);
	m_invMasses.push_back(1.0);
	m_v.push_back(Eigen::Vector3d(0.0, 0.0, 0.0));
	m_a.push_back(Eigen::Vector3d(0.0, 0.0, 0.0));
}

void CParticleData::addParticle(const Eigen::Vector3d& vPos, const Eigen::Vector3d& vGravity)
{
	m_x0.push_back(vPos);
	m_x.push_back(vPos);
	m_oldX.push_back(vPos);
	m_lastX.push_back(vPos);
	m_masses.push_back(1.0);
	m_invMasses.push_back(1.0);
	m_v.push_back(Eigen::Vector3d(0.0, 0.0, 0.0));
	m_a.push_back(vGravity);
}

void CParticleData::setMass(int i, double vMass)
{
	m_masses[i] = vMass;
	if (vMass != 0.0)
		m_invMasses[i] = static_cast<double>(1.0) / vMass;
	else
		m_invMasses[i] = 0.0;
}